<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>投诉事件登记</title>
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/tags/unitedselect/UnitedSelect.js"></script>
<%@ include file="/commons/dateTime.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<script type="text/javascript">
	var optionStatus = "${page_option}";

	function openHouseSelect(){ //打开选房间的页面
		var ownerUrl = "${ctx}/customer_chooseSingleHouseAction.do?method=chooseBuildingMain&isOwnerName=withOwnerName";
		ownerUrl += "&parentFrameId=customerEventEditFrame";
		top.windowOpen(ownerUrl , "chooseBuildFrm", "选择房间",500,800);
	}

	function setHouseInfo(houseId,houseNum,ownerName){ //设置房号
		$("houseNumber").value = houseNum;
		$("houseKeyword").value = houseId;
		$("owners").value = ownerName;
		$("contact").value = ownerName;
	}
	//如果是手工输入房号 则要求手动到后台查询业主信息
	function setOwnerInfo(result){
		var obj =  eval('(' + result.responseText + ')');

		$("houseNumber").value = obj.houseNumber;
		$("houseKeyword").value = obj.houseId;

		$("owners").value = obj.onwerName;
		$("contact").value = obj.onwerName;
	}
	function setSeriousDegreeStatsu(validity){//设置严重程度状态
		var flag = true;
		//001--有效  002--待定  000--无效
		flag = (validity == "001" || validity == "002") ? true:false;
		//修改严重程度
		_changeDisabled("seriousDegreeKeyword",flag);
		//修改紧急程度
		_changeDisabled("emergencyDegreeKeyword",flag);
		//修改备注
		_changeRemark(!flag);
		//修改保存并创建派工单按钮
		$("btn1_42").disabled = !flag;
		$("btn1_12").disabled = !flag;
	}
	function _changeDisabled(elementId,flag){ //修改单选框 状态
		var objArray = document.getElementsByName(elementId,flag);
		for(var i = 0; i < objArray.length; i++){
			objArray[i].disabled = !flag;
		}
	}
    function _changeRemark(flag){ //修改备注验证, true  必填  false  非必填
		var remark = $("remark");
		var tdObject = $("td_remark");
		if(flag == true){
			remark.className = "textareatext validate-char max-length-100 required";
			tdObject.className = "aux_intable_require";
		}else{
			remark.className = "textareatext validate-char max-length-100";
			tdObject.className = "aux_intable_td2";
		}
    }
	function eventContentEventHandle(thiz){//双击事件内容时,文字到右边
		var optionItem = thiz.options[thiz.selectedIndex];
		$("eventContent").value +=  (optionItem.text);
	}
/************各按钮*****************/
	function submitForm(submitStatus){
		var flag = $("custServEventForm").fireEvent("onSubmit");
		if(!flag) return;

		var url = $("custServEventForm").action + "?method=" +  _getSubmitMethod();
		if(submitStatus != null && submitStatus != "undefined")
			url += ("&submitStatus=" + submitStatus);
		$("custServEventForm").action = url;
		$("submitButton").click();
		setButtonStatus(false); //设置按钮不可用
	}
	/**
	 *  DispatchForm 表示创建派工单
	 */
	function submitFormAndCreateDispatchForm(){
		submitForm("dispatchForm_event");
	}
	/**
	 * 保存并归档
	 */
	function submitFormAndArchivism(){
		submitForm("archivism");
	}
	/**
	 * 保存并提交
	 */
	function submitFormAndSubmit(){
		submitForm("submit");
	}

	function _getSubmitMethod(){ //获取提交代码,确定是ADD还是EDIT
		var method;
		if(optionStatus == "isAdd") method = "addCSEvent";
		if(optionStatus == "isEdit") method = "editCSEvent";
		return method;
	}

	function setButtonStatus(status){ //设置按钮状态 true 代表可用 false代表不可用
		$("btn1_42").disabled = !status;
		$("btn1_62").disabled = !status;
		$("btn1_12").disabled = !status;
		$("btn1_22").disabled = !status;
		$("btn1_32").disabled = !status;
	}
	function init(){
		var validityArray = document.getElementsByName("validity");
		for(var i = 0; i < validityArray.length; i++){
			if(validityArray[i].value == "${custEventVO.validity}"){
				validityArray[i].fireEvent("onclick");
				validityArray[i].checked = "checked";
			}
		}
	}
<c:if test="${isFlush}" var="isFlush" scope="request">
	findFrame("main").refleshFrame();
</c:if>
<c:if test="${dispatchForm_event}" var="dispatchForm" scope="request">
 	 	var url = "${ctx}/customerService_dispatchFormAction.do?method=dispatchFormCommonMain&customerEventId=${custEventVO.keyword}";
	 	top.windowOpen(url, "openDispatchMain", "派工单管理", 480, 950,true,"openDispatchMain");
	 	windowClose();
</c:if>
<c:if test="${archivism}" var="archivism" scope="request">
	AskConfirm("您确定将此事件归档吗？","customerEventEditFrame","archivism");
	function archivism(){
	  	var url = "${ctx}/customerService_custServEventAction.do?method=archivism&keyword=${custEventVO.keyword}";
		sendAjaxRequest(url,null,function(result){
			ajaxSubmitException(result.responseText);
			findFrame("main").refleshFrame();
			windowClose();
		});
	}
</c:if>
<c:if test="${submit}" var="submit" scope="request">
  	var url = "${ctx}/customerService_deptCooperationAction.do?method=navigateTaskSubmit&keyword=${custEventVO.keyword}";
  	top.windowOpen(url, "taskSubmit", "任务提交", 210, 450,true,"taskSubmitFrame");
  	windowClose();
</c:if>
</script>
</head>

<body onload="init();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg">
    	<table border="0" cellpadding="0" cellspacing="0">
	      <tr>
	        <td>
	        	<img src="${ctx}/images/ico_Advance.gif" align="absmiddle" />
	        	<span class="window_head_intext">事件登记</span>
	        </td>
	      </tr>
    	</table>
    </td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content">
    <form id="custServEventForm" method="post" class="required-validate"
    	  action="${ctx}/customerService_custServEventAction.do" >
    <input type="submit" id="submitButton" style="display:none">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color">
         <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
          <tr>
            <td valign="top" class="aux_intable_td1">事件编号：</td>
            <td class="aux_intable_td2">
            	${custEventVO.eventNo}
            	<input type="hidden" name="eventNo" id="eventNo" value="${custEventVO.eventNo}">
            	<input type="hidden" name="keyword" id="keyword" value="${custEventVO.keyword}">
            </td>
            <td class="aux_intable_td1">事件区域：</td>
            <td class="aux_intable_td2">
   				<pms:unitedSelect id="eventRegionKeyword"
   								name="eventRegionKeyword"
   								style="width:110px;"
   								dataList="${eventRegions}"
   								optionLabel="name"
   								optionValue="keyword"
   								value="${custEventVO.eventRegionKeyword}"
   								selectText="请选择...">
   				</pms:unitedSelect>
            </td>
          </tr>
          <tr>
            <td valign="top" class="aux_intable_td1">房 号：</td>
            <td class="aux_intable_td2">
            	<table border="0" cellspacing="0" cellpadding="0">
	              <tr>
	                <td><input id="houseNumber" name="houseNumber"
	                		   type="text" class="inputtext validate-char validate-ajax"
	                		   afterInsert="houseNumberMess"
	                		   returnIsTrue="false"
	                		   validateMessage="房号不存在"
	                		   validateUrl="${ctx}/customerService_custServEventAction.do?method=validationHouseNumber"
	                		   onSuccess="setOwnerInfo"
	                		   value="${custEventVO.houseNumber}" size="16" maxlength="10"/>
	                </td>
	                <td width="4"><input type="hidden" id="houseKeyword" name="houseKeyword" value="${custEventVO.houseKeyword}">&nbsp;</td>
	                <td>
	                	<a href="#"  onClick="openHouseSelect();" onFocus="this.blur()">
	                		<img src="${ctx}/images/ico_houesno.GIF" alt="请点选查找房号" border="0" />
	                	</a>
	                	<span id="houseNumberMess"></span>
	                </td>
	              </tr>
            	</table>
            </td>
			<td valign="top" class="aux_intable_td1">详细地点：</td>
            <td valign="top" class="aux_intable_td2">
            	<input id="fullAddress" name="fullAddress" type="text"
            		  class="inputtext validate-char" value="${custEventVO.fullAddress}" size="16"  maxlength="100"/>
            </td>
          </tr>
		  <tr>
		    <td class="aux_intable_td1">客户姓名：</td>
		    <td class="aux_intable_td2">
		    	<input id="owners" name="owners" type="text" class="inputtext "
		    		   value="${custEventVO.owners}" size="16" />
		    </td>
            <td class="aux_intable_td1">预约时间：</td>
            <td class="aux_intable_td2">
            	<table border="0" cellspacing="0" cellpadding="0">
	              <tr>
	                <td>
	                	<input id="appointment" name="appointment" type="text"
	                			class="inputtext validate-dateTime-yyyy-mm-dd-HH:mm:ss" afterInsert="appointmentMessage"
	                			value="${custEventVO.appointment}" size="16" maxlength="16"/>
	                </td>
	                <td width="4">&nbsp;</td>
	                <td><img id="imgDateButton" src="${ctx}/images/ico_clock.gif" width="20" height="20" />
	                	<span id="appointmentMessage"></span>
	              </tr>
            	</table>
            </td>
		  </tr>
		 <tr>
            <td class="aux_intable_td1">联系人：</td>
            <td valign="top" class="aux_intable_require">
            	<input name="contact" type="text"
            		   class="inputtext required validate-char"
            		   validateChar="\\<\\>\\'\\'“”~!#$%^&*=+[\\]{};:/?`|！·￥…\\；：。，》《[]"
            		   maxlength="36"
            		   value="${custEventVO.contact}" size="16" />
            </td>
            <td class="aux_intable_td1">联系电话：</td>
            <td class="aux_intable_td2">
            	<input name="linkPhone" type="text" size="16" maxlength="36"
            		   class="inputtext validate-char" value="${custEventVO.linkPhone}" />
            </td>
		 </tr>
		  <tr>
            <td class="aux_intable_td1">事件性质：</td>
            <td class="aux_intable_require">
   				<pms:unitedSelect id="eventNatureKeyword"
   								name="eventNatureKeyword"
   								style="width:110px;"
   								dataList="${eventNature}"
   								optionLabel="name"
   								optionValue="keyword"
   								isUnited="true"
   								targetId="custServEventKindKeyword"
   								actionName="customerService_custServEventAction"
   								className="select-one-required"
   								value="${custEventVO.eventNatureKeyword}"
   								selectText="请选择...">
   				</pms:unitedSelect>
             </td>
            <td class="aux_intable_td1">事件类型：</td>
            <td class="aux_intable_require">
   				<pms:unitedSelect id="custServEventKindKeyword"
   								name="custServEventKindKeyword"
   								style="width:110px;"
   								optionLabel="name"
   								optionValue="keyword"
   								className="select-one-required"
   								dataList="${custEventKinds}"
   								value="${custEventVO.custServEventKindKeyword}"
   								selectText="请选择...">
   				</pms:unitedSelect>
              </td>
          </tr>
          <tr>
            <td valign="top" class="aux_intable_td1">有效性：</td>
            <td colspan="3" valign="top" class="aux_intable_require">
            <label>
              <input type="radio" name="validity" class="validate-one-required"  status="${custEventVO.validity eq '001'}" value="001" onClick="setSeriousDegreeStatsu('001')" />
              	有 效&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              <input type="radio" name="validity" class="validate-one-required" status="${custEventVO.validity eq '000'}" value="000" onClick="setSeriousDegreeStatsu('000')" />
              	无 效&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              <input type="radio" name="validity" class="validate-one-required" status="${custEventVO.validity eq '002'}" value="002" onClick="setSeriousDegreeStatsu('002');" />
              	待 定</label>
            </td>
          </tr>
		  <tr>
            <td class="aux_intable_td1">严重程度：</td>
            <td class="aux_intable_td2">
   				<pms:unitedSelect id="seriousDegreeKeyword"
   								name="seriousDegreeKeyword"
   								style="width:110px;"
   								optionLabel="name"
   								optionValue="keyword"
   								dataList="${seriousDegrees}"
   								value="${custEventVO.seriousDegreeKeyword}"
   								selectText="请选择...">
   				</pms:unitedSelect>
            </td>
            <td class="aux_intable_td1">紧急程度：</td>
            <td class="aux_intable_td2">
   				<pms:unitedSelect id="emergencyDegreeKeyword"
   								name="emergencyDegreeKeyword"
   								style="width:110px;"
   								optionLabel="name"
   								optionValue="keyword"
   								dataList="${emergencyDegrees}"
   								value="${custEventVO.emergencyDegreeKeyword}"
   								selectText="请选择...">
   				</pms:unitedSelect>
          </tr>
          <tr>
            <td valign="top" class="aux_intable_td1">事件内容：</td>
            <td colspan="3" class="aux_intable_require_more">
            	<table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td >
	   				<pms:unitedSelect id="eventContentRight"
	   								name="eventContentRight" style="width:110px;textareatext"
	   								dataList="${FrequentEvent}" optionLabel="name"
	   								optionValue="keyword"
	   								ondblclick="eventContentEventHandle(this);" multiple="true" size="3"
	   								>
	   				</pms:unitedSelect>
                  </td>
                  <td  class="between_space_both"></td>
                  <td ><textarea name="eventContent" cols="16" rows="3" class="required max-length-150">${custEventVO.eventContent}</textarea></td>
                </tr>
            </table></td>
          </tr>

          <tr>
            <td valign="top" class="aux_intable_td1">备&nbsp;注：</td>
            <td colspan="3" class="aux_intable_td2" id="td_remark">
            	<textarea id="remark" name="remark"
            		cols="36" rows="3"
            		class="textareatext validate-char max-length-100"
            		validateChar="$">${custEventVO.remark}</textarea>
			</td>
          </tr>

          <tr>
            <td class="aux_intable_td1">记录人：</td>
            <td class="aux_intable_td2">
            	${custEventVO.recorder}
            	<input type="hidden" id="recorder" name="recorder" value="${custEventVO.recorder}">
            </td>
            <td class="aux_intable_td1">记录时间：</td>
            <td class="aux_intable_td2">
            	${custEventVO.recorderTime}
            	<input type="hidden" id="recorderTime" name="recorderTime" value="${custEventVO.recorderTime}">
            </td>
          </tr>
        </table>
        </td>
        </tr>
        </table>
	  </td>
	  </form>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
	     <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_41"></td>
                <td class="buttonOffMiddle" id="btn1_42"
                	 onClick="submitFormAndCreateDispatchForm();"
                	 onMouseOver="btn_change_over(4)"
                	 onMouseOut="btn_change_out(4)"
                	 onBlur="btn_change(4)">

                	 <img src="${ctx}/images/ico_sq_fx.gif" alt="" width="14" height="14" border="0" align="absbottom" />&nbsp; 保存并创建派工单
                </td>
                <td class="buttonOffRight" id="btn1_43"></td>
              </tr>
          </table></td>

          <td class="btn_between_space"></td>
          <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_61"></td>
                <td class="buttonOffMiddle" id="btn1_62"
                	onClick="submitFormAndArchivism();"
                	onMouseOver="btn_change_over(6)"
                	onMouseOut="btn_change_out(6)"
                	onBlur="btn_change(6)">

                	<img src="${ctx}/images/ico_principal_rwcl.gif" alt="" width="14" height="14" border="0" align="absbottom" />&nbsp; 保存并归档
                </td>
                <td class="buttonOffRight" id="btn1_63"></td>
      			<td class="btn_between_space"></td>
				<td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_11"></td>
              <td class="buttonOffMiddle" id="btn1_12"
              	  onClick="submitFormAndSubmit();"
              	  onMouseOver="btn_change_over(1)"
              	  onMouseOut="btn_change_out(1)"
              	  onBlur="btn_change(1)">

              	  <img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 保存并提交
              </td>
              <td class="buttonOffRight" id="btn1_13"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td>
        	<table border="0" cellpadding="0" cellspacing="0">
	            <tr>
	              <td class="buttonOffLeft" id="btn1_21"></td>
	              <td class="buttonOffMiddle" id="btn1_22"
	              	  onClick="submitForm();"
	              	  onMouseOver="btn_change_over(2)"
	              	  onMouseOut="btn_change_out(2)"
	              	  onBlur="btn_change(2)">
	              	  <img src="${ctx}/images/ico_yhhk_rp.gif" alt="" width="16"
	              	  	   height="16" border="0" align="absbottom" /> 保 存
	              </td>
	              <td class="buttonOffRight" id="btn1_23"></td>
	            </tr>
        	</table>
        </td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle"
              	  id="btn1_32"
              	  onClick="windowClose();"
              	  onMouseOver="btn_change_over(3)"
              	  onMouseOut="btn_change_out(3)"
              	  onBlur="btn_change(3)">
              	  <img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 关 闭</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
              </tr>
          </table></td>
        </tr>
      </table>
      <p>&nbsp;</p></td>
  </tr>
</table>
<script type="text/javascript">
              Calendar.setup(
              {
	              inputField : "appointment", // ID of the input field
	              ifFormat : "%Y-%m-%d %H:%M:%S", // the date format
	              button : "imgDateButton", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true,
			      showsTime      :    true
              }
              );
</script>
</body>
</html>